package com.cr.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.internal.SessionImpl;

public class HibernateUtil {
	private static EntityManager entityManager;
	public static EntityManagerFactory getEntityManagerFactory() {
		EntityManagerFactory emf = Persistence
				.createEntityManagerFactory("punit");
		entityManager = emf.createEntityManager();
		
		return emf;
	}
	public static SessionImpl getSession() {
		SessionImpl delegate = (SessionImpl) entityManager.getDelegate();
		return delegate;
		
	}
}
